package cn.tedu.front.search.dao.persist.repository.impl;

import cn.tedu.common.pojo.vo.PageData;
import cn.tedu.common.util.PageInfoToPageDataConverter;
import cn.tedu.front.search.dao.persist.mapper.CompanyMapper;
import cn.tedu.front.search.dao.persist.repository.ICompanyRepository;
import cn.tedu.front.search.pojo.po.CompanyPO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CompanyRepository implements ICompanyRepository {

    @Autowired
    private CompanyMapper mapper;

    @Override
    public PageData<CompanyPO> listSearch(Integer pageNum, Integer pageSize) {
        //PageData 使用pageNum从第一页开始
        PageHelper.startPage(pageNum,pageSize);
        List<CompanyPO> list = mapper.listSearch();
        PageInfo<CompanyPO> pageInfo=new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }
}
